package com.example.bbook.services.impl;

import com.example.bbook.entity.UserEntity;
import com.example.bbook.mapper.OrderMapper;
import com.example.bbook.services.DashboardService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class DashboardServiceImpl implements DashboardService {

    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Map<String, Object>> getRankList() {
        List<Map<String, Object>> rankList = new ArrayList<>();
        Map<String, Object> rank = new HashMap<>();

        rank.put("maxNumUser", orderMapper.getMaxNumUser()); // 销量最多的商家
        rank.put("maxGoodsType", orderMapper.getMaxGoodsType());       // 销量最多的种类
        rank.put("maxMoneyUser", orderMapper.getMaxMoneyUser());       // 销售额最多的商家
        rank.put("maxNumGoods", orderMapper.getMaxNumGoods());       // 销售最多的商品
        rank.put("maxEvaGoods", orderMapper.getMaxEvaGoods());       // 评论最多的商品
        rankList.add(rank);
        return rankList;
    }

    @Override
    public List<Map<String, Object>> getSalesMoney() {
        return orderMapper.getMoneyGoodsType();
    }

    @Override
    public List<Map<String, Object>> getSalesAmount() {
        return null;
    }

    @Override
    public List<Map<String, Object>> getGoodsRank() {
        return orderMapper.getGoodsRank();
    }

    @Override
    public List<Map<String, Object>> getOrderContrast() {
        return null;
    }

    @Override
    public List<Map<String, Object>> getGoodsTypeNum() {
        return orderMapper.getNumGoodsType();
    }

    private Map<String, Object> buildMap(String key, Object val) {
        Map<String, Object> resMap = new HashMap<>();
        resMap.put(key, val);
        return resMap;
    }
}
